<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 
 * @property int $uid 
 * @property int $main_uid 
 * @property int $task_id 任务D
 * @property int $sub_task_id 子任务ID
 * @property int $robot_id 企微号ID
 * @property string $to_id 目标微信ID
 * @property int $type 类型:0=自动推送 1=智能推送
 * @property int $trigger_time 触发时间
 * @property int $start_time 发送开始时间
 * @property int $end_time 发送结束时间
 * @property int $msg_total_count 消息总数量
 * @property int $msg_sent_count 消息发送数量
 * @property int $status 发送状态：0=待发送 1=发送中 2=发送完成 3=发送失败 4=已取消
 * @property array $content 发送内容
 * @property int $is_room 发送对象：0=个人 1=群
 * @property array $extra 额外参数
 * @property string $failure_reason 失败原因
 * @property int $is_last_send_item 是否最后一个发送对象：0=否 1=是
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 更新时间
 * @property-read null|ChContact $contact 
 * @property-read null|ChRobot $robot 
 */
class ChSendRecord extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_send_record';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'uid', 'main_uid', 'task_id', 'sub_task_id', 'robot_id', 'to_id', 'type', 'trigger_time', 'start_time', 'end_time', 'msg_total_count', 'msg_sent_count', 'status', 'content', 'is_room', 'extra', 'failure_reason', 'is_last_send_item', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'uid' => 'integer', 'main_uid' => 'integer', 'task_id' => 'integer', 'sub_task_id' => 'integer', 'robot_id' => 'integer', 'type' => 'integer', 'trigger_time' => 'integer', 'start_time' => 'integer', 'end_time' => 'integer', 'msg_total_count' => 'integer', 'msg_sent_count' => 'integer', 'status' => 'integer', 'content' => 'array', 'is_room' => 'integer', 'extra' => 'array', 'is_last_send_item' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];


    public function contact(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChContact::class,'user_id','to_id');
    }

    public function robot()
    {
        return $this->hasOne(ChRobot::class,'id','robot_id');
    }
}
